<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
cfc('core')->checklogin();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$return['diy']=$this->plugin_setting('diy');
$return['setting']=$this->plugin_setting('basic');
if($_RQ['op']=='main'){
    $member=pdo_get('core_members',array('id'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),array('credit1','credit2','mobile','groupid','avatar','nickname'));
	if(!$member){
		exi('找不到会员信息！','error','/index/');
	}
	$user_id=pdo_getcolumn('jy_gohome_user',array('id'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'id');
	if(!$user_id){
		$insert=array(
			'id'=>$_SESSION['uid'],
			'uniacid'=>$_SESSION['uniacid'],
			'mobile'=>$member['mobile'],
			'name'=>$member['realname'],
			'headimg'=>$member['avatar'],
			'sex'=>$member['sex'],
			'createtime'=>TIMESTAMP,
		);
		pdo_insert('jy_gohome_user',$insert);
	}
	$my_days = array(
			array('title'=>'我的预约','icon'=>'icon-form','color'=>'#cc99ff','action'=>'jy_gohome/order/'),
			array('title'=>'会员卡','icon'=>'icon-erweima','color'=>'#cc99ff','action'=>'core/member.card/'),
			array('title'=>'我的优惠券','icon'=>'icon-youhuiquan','color'=>'#cc99ff','action'=>'jy_weishop/coupon.myindex/'),
			array('title'=>'充值记录','icon'=>'icon-chongzhi','color'=>'#cc99ff','action'=>'core/member.log/'),
			array('title'=>'积分日志','icon'=>'icon-jifen','color'=>'#cc99ff','action'=>'core/member.credit_log/list/type=1'),
	);
	$return['setting']['my_days']=$return['setting']['my_days']?:$my_days;
	$user=pdo_get('jy_gohome_user',array('id'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$worker=pdo_get('jy_gohome_worker',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	if($worker['id']){
		$return['isworker']=1;
	}
	$merchid = pdo_getcolumn('jy_gohome_merch',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_SESSION['uid']),'id');
	if($merchid){
		$return['ismerch']=1;
	}
	$return['member']=$member;
	$return['user']=$user;
	$return['item']=array();
	exi($return);
}
//修改用户信息
if($_RQ['op']=='set'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		$data=array(
				'name'=>$postdata['name'],
				'mobile'=>$postdata['mobile'],
				'headimg'=>$postdata['headimg'],
				'address'=>$postdata['address'],
				);
		$user_id=pdo_getcolumn('jy_gohome_user',array('id'=>$_SESSION['uid']),'id');		
		if($user_id){
			pdo_update('jy_gohome_user',$data,array('id'=>$_SESSION['uid']));
			exi('修改成功','','jy_gohome/home/');		 
		}
	}
	$user=pdo_get('jy_gohome_user',array('id'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$member=pdo_get('core_members',array('id'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$return['item']=$user;
	$return['member']=$member;
	exi($return);
	}

